package com.eugenema.util.ExcelUtil;

import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

/**
 * Excel 配置工厂，提供样式等实例
 *
 * @author 马寅广
 * @date 2023/3/16 17:24
 *
 **/
public class ExcelConfigFactory {
    /**
     * 获取标题样式
     * <br/>微软雅黑，字号 9，加粗，居中
     *
     * @author 马寅广
     * @date 2023/3/16 17:26
     *
     * @return 标题样式
     **/
    public static WriteCellStyle getTitleCellStyle() {
        WriteFont contentWriteFont = new WriteFont();
        contentWriteFont.setFontName("Microsoft YaHei");
        contentWriteFont.setFontHeightInPoints((short)9);
        contentWriteFont.setBold(true);

        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        contentWriteCellStyle.setWriteFont(contentWriteFont);
        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        return contentWriteCellStyle;
    }

    /**
     * 获取居中样式
     * <br/>微软雅黑，字号 9，居中
     *
     * @author Eugenema
     * @date 2023/3/16 22:15
     *
     *
     * @return 居中样式
     **/
    public static WriteCellStyle getCenterCellStyle() {
        WriteFont contentWriteFont = new WriteFont();
        contentWriteFont.setFontName("Microsoft YaHei");
        contentWriteFont.setFontHeightInPoints((short)9);

        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        contentWriteCellStyle.setWriteFont(contentWriteFont);
        return contentWriteCellStyle;
    }

    /**
     * 获取居中加粗样式
     * <br/>微软雅黑，字号 9，居中
     *
     * @author Eugenema
     * @date 2023/3/16 22:15
     *
     *
     * @return 居中加粗样式
     **/
    public static WriteCellStyle getCenterBoldCellStyle() {
        WriteFont contentWriteFont = new WriteFont();
        contentWriteFont.setFontName("Microsoft YaHei");
        contentWriteFont.setFontHeightInPoints((short)9);
        contentWriteFont.setBold(true);

        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        contentWriteCellStyle.setWriteFont(contentWriteFont);
        return contentWriteCellStyle;
    }
}
